package com.jx.jingxuan.util;

import android.content.Context;

/**
 * <li>Package:com.jx.jingxuan.Util</li>
 * <li>Author: Administrator  </li>
 * <li>Date: 2019/3/18</li>
 * <li>Description:   </li>
 */
public class Tools {
    public static int dip2px(Context context, float dipValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f);
    }

    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }

    public static int getDisplayWidth(Context context) {
        return context.getResources().getDisplayMetrics().widthPixels;
    }

    public static int getDisplayHeight(Context context) {
        return context.getResources().getDisplayMetrics().heightPixels;
    }
}
